package com.daotingli.backendprograms.Repository.Register;

import com.daotingli.backendprograms.DB.SpringDB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;

@Component
public class RegisterRepository {
    @Autowired
    private SpringDB springDB;

    public Map register(String username1, String password1, String identity1,String userphone1) {
        JdbcTemplate  jdbcTemplate=springDB.getJdbcTemplate();
        String sql="insert into t_user(username,password,identity,userphone) values(?,?,?,?)";
//        // 插入
        int count=jdbcTemplate.update(sql,username1,password1,identity1,userphone1);
        Map map=new HashMap();
        if(count>0)
        {
            map.put("code",200);
            map.put("msg","注册成功");
            map.put("data",count);
        }else {
            map.put("code",400);
            map.put("msg","注册失败");
            map.put("data",count);
        }

        return map;
    }
}
